<div class="form-item clearfix">
	<div class="input-label">任务单号</div>
	<div class="input-item">
	<if condition="$data neq NULL">
		<if condition="$data['noedit'] neq 1">
			<input type="text" name="matter_id" class="form-control w150" value="{$data['matter_id']}">
		<else/>
			{$data['matter_id']}
		</if>
	<else/>
		<input type="text" name="matter_id" class="form-control w150">
	</if>
		
	</div>
</div>
<div class="form-item clearfix">
	<div class="input-label"><if condition="$data eq NULL or $data['noedit'] neq 1"><span class="asterisk">*</span></if>工作类型</div>
	<div class="input-item">
	<if condition="$data neq NULL">
		<if condition="$data['noedit'] neq 1">
			<select name="work_type2" class="form-control select-add w150" autocomplete="off">
				<option value="-10" t-name="">请选择</option>
				<foreach name="work_type" item="vo">
					<option value="{$vo['name1']}" t-name="{$vo['name3']}" <if condition="$data['work_type'] eq $vo['name1']">selected</if>>{$vo['name2']}</option>
				</foreach>
			</select>
			<span class="input-prompt ml10"><i class="glyphicon glyphicon-exclamation-sign mr5"></i><em style="font-style:normal;">{$data['work_type_name']}</em></span>
			<span class="error-item">必填项</span>
		<else/>
			{$data['work_name']}
		</if>
	<else/>
		<select name="work_type1" class="form-control select-add w150" autocomplete="off">
			<option value="-10" t-name="">请选择</option>
			<foreach name="work_type" item="vo">
				<option value="{$vo['name1']}" t-name="{$vo['name3']}">{$vo['name2']}</option>
			</foreach>
		</select>
		<span class="input-prompt hide ml10"><i class="glyphicon glyphicon-exclamation-sign mr5"></i><em style="font-style:normal;">{$data['work_type_name']}</em></span>
		<span class="error-item">必填项</span>
	</if>
	</div>
</div>
<div class="form-item clearfix">
	<div class="input-label"><if condition="$data eq NULL or $data['noedit'] neq 1"><span class="asterisk">*</span></if>工作内容</div>
	<div class="input-item">
	<if condition="$data neq NULL">
		<if condition="$data['noedit'] neq 1">
			<textarea name="work_content2" class="form-control w500 h150" autocomplete="off">{$data['work_content']}</textarea>
			<span class="error-item">必填项</span>
		<else/>
			{$data['work_content']}
		</if>
	<else/>
		<textarea name="work_content1" class="form-control w500 h150" autocomplete="off"></textarea>
	</if>
	</div>
</div> 
<div class="load_foot">
	<if condition="$data['noedit'] neq 1"><if condition="$data['id'] neq NULL"><button type="button" class="btn user-delete left" zid="{$data['id']}">删除</button></if><button type="button" class="btn user-affirm">确认</button></if><button type="button" class="btn btn-default user-cancel ml10" data-dismiss="modal">取消</button>
</div>
<script type="text/javascript">
$(function(){
	//删除
	$(".user-delete").click(function(){
		var zid = $(this).attr('zid');
		$('#modal-delete .delete-confirm').attr('zid',zid);
		$('#modal-delete').fadeIn().addClass('opacity');
		$('.mask').fadeIn();
	})
	
	$("[name='work_type1']").select2();
	$("[name='work_type2']").select2();
	//提交
	$('.user-affirm').click(function(){
		var tag = true,
			mid = "{$data['id']}";
		
		if(mid){
			if($("[name='work_type2']").val()==-10){
				$("[name='work_type2']").nextAll('.error-item').show();
				tag = false;
			}
			if($("[name='work_content2']").val()==''){
				$("[name='work_content2']").next('.error-item').show();
				tag = false;
			}
			if($("[name='pid_edit']").val()==-10){
				$("[name='pid_edit']").nextAll('.error-item').show();
				tag = false;
			}
			if($("[name='fill_edit']").val()==-10){
				$("[name='fill_edit']").nextAll('.error-item').show();
				tag = false;
			}
		}else{
			if($("[name='work_type1']").val()==-10){
				$("[name='work_type1']").nextAll('.error-item').show();
				tag = false;
			}
			if($("[name='work_content1']").val()==''){
				$("[name='work_content1']").next('.error-item').show();
				tag = false;
			}
			if($("[name='pid']").val()==-10){
				$("[name='pid']").nextAll('.error-item').show();
				tag = false;
			}
			if($("[name='fill_post']").val()==-10){
				$("[name='fill_post']").nextAll('.error-item').show();
				tag = false;
			}
		}
		if(tag){
			var matter_id = $("[name='matter_id']").val(),
				tdate = $("[name='date']").val(),
				tdate2 = $("[name='start_date']").val(),
				tdate3 = $("[name='end_date']").val(),
				ttype = $('.schedule_btn .active').attr('type'),
				pid = $("[name='pid']").find('option:selected').val(),
				fill = $("[name='fill_post']").find('option:selected').val(),
				pid2 = $("[name='pid_edit']").find('option:selected').val(),
				fill2 = $("[name='fill_edit']").find('option:selected').val();
			if(mid){
				var work_type = $("[name='work_type2']").val(),
					work_content = $("[name='work_content2']").val();
				$.ajax({
					type:"POST",
					async:false,
					dataType:"json",
					data:{"matter_id":matter_id,"work_type":work_type,"work_content":work_content,"ttype":ttype,"pid":pid2,"fill":fill2,"id":mid},
					url:"__APP__/Index/schedule_list_doedit",
					success:function(data){
						$('#edit_modal').hide();
						success_pop(data.status,data.msg);
					}
				});
			}else{
				var work_type = $("[name='work_type1']").val(),
					work_content = $("[name='work_content1']").val();
				$.ajax({
					type:"POST",
					async:false,
					dataType:"json",
					data:{"matter_id":matter_id,"work_type":work_type,"work_content":work_content,"tdate":tdate,"tdate2":tdate2,"tdate3":tdate3,"ttype":ttype,"pid":pid,"fill":fill},
					url:"__APP__/Index/schedule_list_doadd",
					success:function(data){
						$('#date_modal').hide();
						success_pop(data.status,data.msg);
					}
				});
			}
		}
	})
	//工作类型
	$("[name='work_type1']").change(function(){
		if($(this).val()==-10){
			$(this).nextAll('.input-prompt').hide();
		}else{
			var name = $(this).find("option:selected").attr('t-name');
			$(this).nextAll('.input-prompt').show().find('em').html(name);
			$(this).nextAll('.error-item').hide();
		}
	})
	$("[name='work_type2']").change(function(){
		if($(this).val()==-10){
			$(this).nextAll('.input-prompt').hide();
		}else{
			var name = $(this).find("option:selected").attr('t-name');
			$(this).nextAll('.input-prompt').show().find('em').html(name);
			$(this).nextAll('.error-item').hide();
		}
	})
	//取消提示
	$("[name='matter_id'],[name='work_content']").focus(function(){
		$(this).next('.error-item').hide();
	})
});
</script>
</body>
</html>
